/**
* nicExample
* @description: An example button plugin for nicEdit
* @requires: nicCore, nicPane, nicAdvancedButton
* @author: Brian Kirchoff
* @version: 0.9.0
*/
 
/* START CONFIG */
var nicCiteLinkOptions = {
    buttons : {
        'citelink' : {name : __('Insert CiteLink'), type : 'nicCiteLinkButton'}
    }/* NICEDIT_REMOVE_START */,iconFiles : {'citelink' : '/imgs/icons/16x16/cite-link.png'}/* NICEDIT_REMOVE_END */
};
/* END CONFIG */
 
var nicCiteLinkButton = nicEditorAdvancedButton.extend({  
    addPane : function() {
    },

    mouseClick: function (e) {
        var citelink = global.clipboard.cite_link();
        this.ln = this.ne.selectedInstance.selElm().parentTag('A');
        if (!this.ln) {
            if (citelink && citelink.length > 0) {
                this.ne.nicCommand('unlink',[]);
                this.ne.nicCommand('createlink', citelink);
                this.ln = this.findElm('A', 'href', citelink);
                //add cite icon and bind click event
                $(this.ln).addClass('cite-link');
                $(this.ln).click (function (event) {
                    trigger_citelink_click(this)
                    return false;
                });

                this.removePane();
            } else {
                alert('Oops~ No cite info to be found in clipboard.')
            }
        }
    },
});
 
nicEditors.registerPlugin(nicPlugin,nicCiteLinkOptions);


